﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
                    xmlns:Tfsvm="clr-namespace:VisualWip.TFS2010Providers;assembly=TFS2010Providers"
                    >

    <BitmapImage x:Key="Tfs2010WorkItemWorkProvider_QueryTypeFlatList"  UriSource="pack://application:,,,/TFS2010Providers;component/Images/teamexplorerflatlist.png" />
    <BitmapImage x:Key="Tfs2010WorkItemWorkProvider_QueryTypeOneHop"  UriSource="pack://application:,,,/TFS2010Providers;component/Images/teamexplorerdirectlink.png" />
    <BitmapImage x:Key="Tfs2010WorkItemWorkProvider_QueryTypeTree"  UriSource="pack://application:,,,/TFS2010Providers;component/Images/teamexplorertree.png" />
    <BitmapImage x:Key="Tfs2010WorkItemWorkProvider_FolderExpanded"  UriSource="pack://application:,,,/TFS2010Providers;component/Images/teamexplorerfolderexpanded.png" />
    <BitmapImage x:Key="Tfs2010WorkItemWorkProvider_FolderCollapsed"  UriSource="pack://application:,,,/TFS2010Providers;component/Images/teamexplorerfoldercollapsed.png" />
    <BitmapImage x:Key="Tfs2010WorkItemWorkProvider_MyQueries"  UriSource="pack://application:,,,/TFS2010Providers;component/Images/teamexplorermyqueries.png" />
    <BitmapImage x:Key="Tfs2010WorkItemWorkProvider_TeamQueries"  UriSource="pack://application:,,,/TFS2010Providers;component/Images/teamexplorerteamqueries.png" />

    <Tfsvm:QueryItemToImageSourceConverter x:Key="imageConverter" />

    <Style x:Key="ColumnTypeStyle" TargetType="{x:Type FrameworkElement}">
        <Style.Triggers>
            <DataTrigger Binding="{Binding SettingsWindowName}" Value="Work-in-progress group">
                <Setter Property="Visibility" Value="Collapsed"/>
            </DataTrigger>
            <DataTrigger Binding="{Binding SettingsWindowName}" Value="Doing done column">
                <Setter Property="Visibility" Value="Collapsed"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="QuerysStyle" TargetType="{x:Type TreeViewItem}">
        <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
        <Setter Property="FontWeight" Value="Normal" />
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="FontWeight" Value="Bold" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <HierarchicalDataTemplate x:Key="QuerysItemsTemplate" ItemsSource="{Binding Children}">
        <StackPanel Orientation="Horizontal">
            <Image >
                <Image.Source>
                    <MultiBinding Converter="{StaticResource imageConverter}">
                        <Binding Path="."/>
                        <Binding Path="IsExpanded"/>
                    </MultiBinding>
                </Image.Source>
            </Image>
            <TextBlock Text="{Binding Name}" />
        </StackPanel>
    </HierarchicalDataTemplate>


    <DataTemplate DataType="{x:Type Tfsvm:TfsWorkSingleQuerySettingsViewModel}">
        <ContentControl Content="{Binding .}" ContentTemplate="{DynamicResource TfsWorkSingleQuerySettingsView}" />
    </DataTemplate>

    <DataTemplate DataType="{x:Type Tfsvm:TfsWorkDoingDoneSettingsViewModel}">
        <ContentControl Content="{Binding .}" ContentTemplate="{DynamicResource TfsWorkDualQuerySettingsView}" />
    </DataTemplate>

    <DataTemplate DataType="{x:Type Tfsvm:TfsWorkInProgressGroupSettingsViewModel}">
        <ContentControl Content="{Binding .}" ContentTemplate="{DynamicResource TfsWorkDualQuerySettingsView}" />
    </DataTemplate>

    <DataTemplate DataType="{x:Type Tfsvm:TfsWorkDoingSettingsViewModel}">
        <ContentControl Content="{Binding .}" ContentTemplate="{DynamicResource TfsWorkDualQuerySettingsView}" />
    </DataTemplate>

    <DataTemplate DataType="{x:Type Tfsvm:TfsWorkDoneSettingsViewModel}">
        <ContentControl Content="{Binding .}" ContentTemplate="{DynamicResource TfsWorkDualQuerySettingsView}" />
    </DataTemplate>

    <DataTemplate x:Key="TfsWorkSingleQuerySettingsView">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="2" />
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Label Content="Work in progress limit" />
            <TextBox Grid.Column="2" Text="{Binding TotalWorkInProgressLimit, Mode=TwoWay}" />
            <Label Grid.Row="1" Content="Work item size" />
            <ComboBox Grid.Row="1" Grid.Column="2" Height="23" Name="workItemSizeComboBox" ItemsSource="{Binding Sizes}" DisplayMemberPath="Name" SelectedItem="{Binding Size,Mode=TwoWay}" />
            <Label Grid.Row="2" Content="Column type" />
            <ComboBox Grid.Row="2" Grid.Column="2" Height="23" Name="columnTypeComboBox" ItemsSource="{Binding ColumnTypes}" DisplayMemberPath="Name" SelectedItem="{Binding ColumnType,Mode=TwoWay}" />
            <StackPanel Grid.Row="3"  Grid.Column="2" Orientation="Horizontal">
                <CheckBox  VerticalAlignment="Center" IsChecked="{Binding AvailableChecked, Mode=TwoWay}" />
                <Label Content="Avalible slots" />
            </StackPanel>
            <StackPanel Grid.Row="4"  Grid.Column="2" Orientation="Horizontal">
                <CheckBox  VerticalAlignment="Center" IsChecked="{Binding DownloadDisplayFieldsOnly, Mode=TwoWay}" />
                <Label Content="Only show the field that are defiend in the query" />
            </StackPanel>
            <TextBlock Grid.Row="5"  Grid.Column="2" TextWrapping="Wrap">Select this option if you only want the fields defiened as columns in the team query to be shown. This will improve performance.</TextBlock>

            <Label Grid.Row="6" Grid.ColumnSpan="3" Content="Select query that will populate this column" />
            <TreeView Grid.Row="7" Grid.ColumnSpan="3" ItemsSource="{Binding Querys.Children}" ItemContainerStyle="{StaticResource QuerysStyle}" ItemTemplate="{StaticResource QuerysItemsTemplate}" />
        </Grid>
    </DataTemplate>

    <DataTemplate x:Key="TfsWorkDualQuerySettingsView">
        <Grid >
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition />
                <RowDefinition Height="Auto"/>
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="150" />
                <ColumnDefinition Width="2" />
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            <Label Content="Work in progress limit" />
            <TextBox Text="{Binding TotalWorkInProgressLimit, Mode=TwoWay}" Grid.Column="2" />
            <Label Grid.Row="1" Content="Work item size" />
            <ComboBox Grid.Row="1" Grid.Column="2" Height="23" ItemsSource="{Binding Sizes}" DisplayMemberPath="Name" SelectedItem="{Binding Size,Mode=TwoWay}" />
            <Label Grid.Row="2" Content="Column type" Style="{StaticResource ResourceKey=ColumnTypeStyle}" />
            <ComboBox Grid.Row="2" Grid.Column="2" Height="23" ItemsSource="{Binding ColumnTypes}" DisplayMemberPath="Name" SelectedItem="{Binding ColumnType,Mode=TwoWay}" Style="{StaticResource ResourceKey=ColumnTypeStyle}"/>
            <StackPanel Grid.Row="3"  Grid.Column="2" Orientation="Horizontal">
                <CheckBox  VerticalAlignment="Center" IsChecked="{Binding DownloadDisplayFieldsOnly, Mode=TwoWay}" />
                <Label Content="Only show the field that are defiend in the query" /><Expander />
            </StackPanel>
            <TextBlock Grid.Row="4"  Grid.Column="2" TextWrapping="Wrap">Select this option if you only want the fields defiened as columns in the team query to be shown. This will improve performance.</TextBlock>
            <Label Grid.Row="5" Grid.ColumnSpan="3" Content="Select first query">
                <Label.Style>
                    <Style TargetType="{x:Type Label}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding SettingsWindowName}" Value="Work-in-progress group">
                                <Setter Property="Content" Value="Select first query"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding SettingsWindowName}" Value="Doing column">
                                <Setter Property="Content" Value="Select first query. This query will populate the column with work items"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding SettingsWindowName}" Value="Done column">
                                <Setter Property="Content" Value="Select first query. This query will be used to for calculations"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Label.Style>
            </Label>
            <TreeView  ItemsSource="{Binding FirstQueries.Children}" Grid.Row="6" Grid.ColumnSpan="3"  ItemContainerStyle="{StaticResource QuerysStyle}" ItemTemplate="{StaticResource QuerysItemsTemplate}" />
          <Label Grid.Row="7" Grid.ColumnSpan="3" Content="Select second query">
                <Label.Style>
                    <Style TargetType="{x:Type Label}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding SettingsWindowName}" Value="Work-in-progress group">
                                <Setter Property="Content" Value="Select second query"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding SettingsWindowName}" Value="Doing column">
                                <Setter Property="Content" Value="Select second query. This query will be used to for calculations"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding SettingsWindowName}" Value="Done column">
                                <Setter Property="Content" Value="Select second query. This query will populate the column with work items"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Label.Style>
            </Label>
            <TreeView  ItemsSource="{Binding SecondQueries.Children}" Grid.Row="8" Grid.ColumnSpan="3"  ItemContainerStyle="{StaticResource QuerysStyle}" ItemTemplate="{StaticResource QuerysItemsTemplate}" />
        </Grid>
    </DataTemplate>
    
    <ribbon:RibbonGroup  x:Key="Tfs2010WorkItemWorkProvider" Header="{Binding HeaderName}">
        <ribbon:RibbonButton 
										 LargeImageSource="{StaticResource ResourceKey=Column_Single}"
										 Label="Add Single column"
                                         Command="{Binding AddSingleColumnCommand}" />
        <ribbon:RibbonSplitButton
                Label = "Add Doing/Done group"
                Command = "{Binding AddDoingDoneGroupCommand}"
                LargeImageSource ="{StaticResource ResourceKey=Column_Group}">
            <ribbon:RibbonGallery>
                <ribbon:RibbonButton 
										 LargeImageSource="{StaticResource ResourceKey=Column_Group}"
										 Label="Add Work-in-progress group column"
                                         Command="{Binding AddWorkInProgressGroupCommand}" />

                <ribbon:RibbonButton 
										 LargeImageSource="{StaticResource ResourceKey=Column_Doing}"
										 Label="Add Doing column"
                                         Command="{Binding AddDoingColumnCommand}" />
                <ribbon:RibbonButton 
										 LargeImageSource="{StaticResource ResourceKey=Column_Done}"
										 Label="Add Done column"
                                         Command="{Binding AddDoneColumnCommand}" />
            </ribbon:RibbonGallery>
        </ribbon:RibbonSplitButton>
        <ribbon:RibbonButton 
										 LargeImageSource="{StaticResource ResourceKey=Column_WorkItem}"
										 Label="Add Single work item column"
                                         Command="{Binding AddSingleWorkItemColumnCommand}" />

    </ribbon:RibbonGroup>

</ResourceDictionary>